package main

func isUpper(w byte) bool {
	return w >= 'A' && w <= 'Z'
}

func detectCapitalUse(word string) bool {
	if len(word) < 2 {
		return true
	}
	if isUpper(word[0]) {
		upper := isUpper(word[1])
		// 全大写
		for i := 2; i < len(word); i++ {
			w := word[i]
			if isUpper(w) != upper {
				return false
			}
		}
	} else {
		for i := 1; i < len(word); i++ {
			w := word[i]
			if isUpper(w) {
				return false
			}
		}
	}
	return true
}

func main() {
	println(detectCapitalUse(""))
	println(detectCapitalUse("W"))
	println(detectCapitalUse("US"))
	println(detectCapitalUse("Us"))
	println(detectCapitalUse("USA"))
	println(detectCapitalUse("FlaG"))
}
